﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Import
{
    [Serializable]
    public class ImportSettings
    {
        public enum ImportValidations
        {
            MissingTimeCode = 1,
            WrongTimeCodeFormat = 2,
            WrongTimeCodeSequence = 3,
            HourResetTimeCode = 4,
            EmptyRow = 5
        }
        public Dictionary<ImportValidations, bool> Validations { get; set; }

        public enum ImportAnnotations
        {
            Actor = 1,
            Director = 2,
            HourReset = 3
        }
        public Dictionary<ImportAnnotations, string[]> Annotations { get; set; }

        [Serializable]
        public class HeaderTable
        {
            public CellInfo Translator { get; set; }
            public CellInfo Keyword { get; set; }
            public CellInfo Project { get; set; }
            public CellInfo Episode { get; set; }
            public CellInfo OriginalTitle { get; set; }
            public CellInfo TranslatedTitle { get; set; }
            public CellInfo RunningTime { get; set; }

            public HeaderTable()
            {
                this.Translator = new CellInfo();
                this.TranslatedTitle = new CellInfo();
                this.Keyword = new CellInfo();
                this.Project = new CellInfo();
                this.Episode = new CellInfo();
                this.OriginalTitle = new CellInfo();
                this.TranslatedTitle = new CellInfo();
                this.RunningTime = new CellInfo();
            }
        }

        [Serializable]
        public class ContentTable
        {
            public int Index { get; set; }
            public bool OmitFirstRow { get; set; }
            public CellInfo TimeCode { get; set; }
            public CellInfo Character { get; set; }
            public CellInfo Dialogue { get; set; }

            public ContentTable()
            {
                this.TimeCode = new CellInfo();
                this.Character = new CellInfo();
                this.Dialogue = new CellInfo();
            }
        }

        [Serializable]
        public class Tables
        {
            public HeaderTable Header { get; set; }
            public ContentTable Content { get; set; }

            public Tables()
            {
                this.Header = new HeaderTable();
                this.Content = new ContentTable();
            }
        }

        public enum LoopParserTypes
        {
            ByWords = 1,
            ByTime = 2
        }
        public Dictionary<LoopParserTypes, int> LoopParsers { get; set; }

        public Tables TablesInfo { get; set; }
        public int UserId { get; set; }

        public ImportSettings()
        {
            this.TablesInfo = new Tables();

            this.Annotations = new Dictionary<ImportAnnotations, string[]>()
            {
                {ImportAnnotations.Actor, new string[] {"", ""}},
                {ImportAnnotations.Director, new string[] {"{", "}"}},
                {ImportAnnotations.HourReset, new string[] { new TimeCode().ToString() }}
            };

            this.Validations = new Dictionary<ImportValidations, bool>
            {
                {ImportValidations.MissingTimeCode, true},
                {ImportValidations.WrongTimeCodeFormat, true},
                {ImportValidations.WrongTimeCodeSequence, true},
                {ImportValidations.HourResetTimeCode, true},
                {ImportValidations.EmptyRow, true}
            };

            this.LoopParsers = new Dictionary<LoopParserTypes, int>();
        }
    }
}
